package com.diandian.backend.product.param;

import com.diandian.backend.product.constants.DianDianProductConstant;
import com.diandian.backend.product.dto.ProductOfflineBrandTreeAddParamDTO;
import com.diandian.base.boot.starter.exception.DefaultException;

import java.io.Serializable;
import java.util.UUID;

public class ProductOfflineBrandTreeAddParam implements Serializable {

	private String type;
	private String nodeCode;
	private String nodeName;
	private String parentNodeCode;
	private String remark;
	private String createUserId;
	private String createUserName;

	private String belong;
	private String orgId;
	private String orgCode;

	public void check(){
		if(this.nodeCode == null || "".equals(this.nodeCode)){
//			throw new DefaultException("节点编码不能为空");
			this.nodeCode = "md_" + UUID.randomUUID().toString().replace("-", "");
		}
		if(this.nodeName == null || "".equals(this.nodeName)){
			throw new DefaultException("节点编码不能为空");
		}
		if(this.parentNodeCode == null || "".equals(this.parentNodeCode)){
			this.parentNodeCode = DianDianProductConstant.TREE_NODE_CODE_TOP;
		}
		if(this.parentNodeCode.equals(DianDianProductConstant.TREE_NODE_CODE_UNGROUP)){
			throw new DefaultException("当前节点不能新增下级节点");
		}
		if(this.belong == null || "".equals(this.belong)){
			throw new DefaultException("归属标识不能为空");
		}
	}

	public ProductOfflineBrandTreeAddParamDTO toDTO(){
		ProductOfflineBrandTreeAddParamDTO dto = new ProductOfflineBrandTreeAddParamDTO();
		dto.setType(this.type);
		dto.setNodeCode(this.nodeCode);
		dto.setNodeName(this.nodeName);
		dto.setParentNodeCode(this.parentNodeCode);
		dto.setRemark(this.remark);
		dto.setBelong(this.belong);
		dto.setCreateUserId(this.createUserId);
		dto.setCreateUserName(this.createUserName);
		dto.setOrgId(this.orgId);
		dto.setOrgCode(this.orgCode);
		return dto;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getNodeCode() {
		return nodeCode;
	}

	public void setNodeCode(String nodeCode) {
		this.nodeCode = nodeCode;
	}

	public String getNodeName() {
		return nodeName;
	}

	public void setNodeName(String nodeName) {
		this.nodeName = nodeName;
	}

	public String getParentNodeCode() {
		return parentNodeCode;
	}

	public void setParentNodeCode(String parentNodeCode) {
		this.parentNodeCode = parentNodeCode;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getBelong() {
		return belong;
	}

	public void setBelong(String belong) {
		this.belong = belong;
	}

	public String getCreateUserId() {
		return createUserId;
	}

	public void setCreateUserId(String createUserId) {
		this.createUserId = createUserId;
	}

	public String getCreateUserName() {
		return createUserName;
	}

	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}

	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
}
